<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
session_start();
if(isset($_REQUEST['btnUpdateAuthor']))
{
    $AuthorID = $_REQUEST['txtAuthorID'];
    $AuthorFirstName = $_REQUEST['txtAuthorFirstName'];
    $AuthorMiddleName = $_REQUEST['txtAuthorMiddleName'];
    $AuthorLastName = $_REQUEST['txtAuthorLastName'];

    $AuthorMiddleName = ($AuthorMiddleName == '' ? NULL : $AuthorMiddleName);

    require '../lib/util.php';
    $updateSql = "UPDATE ref_AUTHORS SET FirstName = '". $AuthorFirstName ."', MiddleName = '". $AuthorMiddleName ."', LastName = '". $AuthorLastName ."' WHERE ID = " . $AuthorID;
    $updateRs = executeSqlQuery($updateSql);
    $rowCount = mysql_num_rows($updateRs);
    
    if ($updateRs)
    {
        $_SESSION['InfoMsg'] = "Record has been updated successfully.";
        header("Location:../refEditAuthors.php?id=" . $AuthorID);
    }
    else
    {
        $_SESSION['InfoMsg'] = "Record is not";
        header("Location:../refEditAuthors.php?id=" . $AuthorID);
    }
}
?>
